package frame.options.sdn.create;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.DocumentListener;

import model.components.networks.sdn.SdnNetworks;

@SuppressWarnings("serial")
public class CreateSdnSelectPanel extends JPanel 
{	
	private JLabel networksNumberLabel;
	public JLabel getNetworksNumberLabel(){ return networksNumberLabel; }
	public void setNetworksNumberLabel( JLabel networksNumberLabel ){ this.networksNumberLabel = networksNumberLabel; }
	
	private JTextField networksNumberTextField;
	public JTextField getNetworksNumberTextField(){ return networksNumberTextField; }
	public void setNetworksNumberTextField( JTextField networksNumberTextField ){ this.networksNumberTextField = networksNumberTextField; }
	
	private JLabel routersNumberLabel;
	public JLabel getRoutersNumberLabel(){ return routersNumberLabel; }
	public void setRoutersNumberLabel( JLabel routersNumberLabel ){ this.routersNumberLabel = routersNumberLabel; }
	
	private JTextField minRoutersNumberTextField;
	public JTextField getMinRoutersNumberTextField(){ return minRoutersNumberTextField; }
	public void setMinRoutersNumberTextField( JTextField minRoutersNumberTextField ){ this.minRoutersNumberTextField = minRoutersNumberTextField; }
	
	private JTextField maxRoutersNumberTextField;
	public JTextField getMaxRoutersNumberTextField(){ return maxRoutersNumberTextField; }
	public void setMaxRoutersNumberTextField( JTextField maxRoutersNumberTextField ){ this.maxRoutersNumberTextField = maxRoutersNumberTextField; }
	
	private JLabel switchesNumberLabel;
	public JLabel getSwitchesNumberLabel(){ return switchesNumberLabel; }
	public void setSwitchesNumberLabel( JLabel switchesNumberLabel ){ this.switchesNumberLabel = switchesNumberLabel; }

	private JTextField minSwitchesNumberTextField;
	public JTextField getMinSwitchesNumberTextField(){ return minSwitchesNumberTextField; }
	public void setMinSwitchesNumberTextField( JTextField minSwitchesNumberTextField ){ this.minSwitchesNumberTextField = minSwitchesNumberTextField; }
	
	private JTextField maxSwitchesNumberTextField;
	public JTextField getMaxSwitchesNumberTextField(){ return maxSwitchesNumberTextField; }
	public void setMaxSwitchesNumberTextField( JTextField maxSwitchesNumberTextField ){ this.maxSwitchesNumberTextField = maxSwitchesNumberTextField; }
	
	private JLabel serversNumberLabel;
	public JLabel getServersNumberLabel(){ return serversNumberLabel; }
	public void setServersNumberLabel( JLabel serversNumberLabel ){ this.serversNumberLabel = serversNumberLabel; }
	
	private JTextField minServersNumberTextField;
	public JTextField getMinServersNumberTextField(){ return minServersNumberTextField; }
	public void setMinServersNumberTextField( JTextField minServersNumberTextField ){ this.minServersNumberTextField = minServersNumberTextField; }
	
	private JTextField maxServersNumberTextField;
	public JTextField getMaxServersNumberTextField(){ return maxServersNumberTextField; }
	public void setMaxServersNumberTextField( JTextField maxServersNumberTextField ){ this.maxServersNumberTextField = maxServersNumberTextField; }
	
	private JLabel osLabel;
	public JLabel getOSlabel(){ return osLabel; }
	public void setOSlabel( JLabel osLabel ){ this.osLabel = osLabel; }
	
	private JTextField linuxPercentageTextField;
	public JTextField getLinuxPercentageTextField(){ return linuxPercentageTextField; }
	public void setLinuxPercentageTextField( JTextField linuxPercentageTextField ){ this.linuxPercentageTextField = linuxPercentageTextField; }

	private JTextField windowsPercentageTextField;
	public JTextField getWindowsPercentageTextField(){ return windowsPercentageTextField; }
	public void setWindowsPercentageTextField( JTextField windowsPercentageTextField ){ this.windowsPercentageTextField = windowsPercentageTextField; }
	
	private JTextField solarisPercentageTextField;
	public JTextField getSolarisPercentageTextField(){ return solarisPercentageTextField; }
	public void setSolarisPercentageTextField( JTextField solarisPercentageTextField ){ this.solarisPercentageTextField = solarisPercentageTextField; }

	private JTextField androidPercentageTextField;
	public JTextField getAndroidPercentageTextField(){ return androidPercentageTextField; }
	public void getAndroidPercentageTextField( JTextField androidPercentageTextField ){ this.androidPercentageTextField = androidPercentageTextField; }
	
	private JLabel cpuLabel;
	public JLabel getCPUlabel(){ return cpuLabel; }
	public void setCPUlabel( JLabel cpuLabel ){ this.cpuLabel = cpuLabel; }
	
	private JTextField minCPUtextField;
	public JTextField getMinCPUtextField(){ return minCPUtextField; }
	public void setMinCPUtextField( JTextField minCPUtextField ){ this.minCPUtextField = minCPUtextField; }
	
	private JTextField maxCPUtextField;
	public JTextField getMaxCPUtextField(){ return maxCPUtextField; }
	public void setMaxCPUtextField( JTextField maxCPUtextField ){ this.maxCPUtextField = maxCPUtextField; }
	
	private JLabel cpuPriceLabel;
	public JLabel getCPUpriceLabel(){ return cpuPriceLabel; }
	public void setCPUpriceLabel( JLabel cpuPriceLabel ){ this.cpuPriceLabel = cpuPriceLabel; }
	
	private JTextField minCPUpriceTextField;
	public JTextField getMinCPUpriceTextField(){ return minCPUpriceTextField; }
	public void setMinCPUpriceTextField( JTextField minCPUpriceTextField ){ this.minCPUpriceTextField = minCPUpriceTextField; }
	
	private JTextField maxCPUpriceTextField;
	public JTextField getMaxCPUpriceTextField(){ return maxCPUpriceTextField; }
	public void setMaxCPUpriceTextField( JTextField maxCPUpriceTextField ){ this.maxCPUpriceTextField = maxCPUpriceTextField; }
	
	private JLabel ramLabel;
	public JLabel getRAMlabel(){ return ramLabel; }
	public void setRAMlabel( JLabel ramLabel ){ this.ramLabel = ramLabel; }
	
	private JTextField minRAMtextField;
	public JTextField getMinRAMtextField(){ return minRAMtextField; }
	public void setMinRAMtextField( JTextField minRAMtextField ){ this.minRAMtextField = minRAMtextField; }
	
	private JTextField maxRAMtextField;
	public JTextField getMaxRAMtextField(){ return maxRAMtextField; }
	public void setMaxRAMtextField( JTextField maxRAMtextField ){ this.maxRAMtextField = maxRAMtextField; }

	private JLabel ramPriceLabel;
	public JLabel getRAMpriceLabel(){ return ramPriceLabel; }
	public void setRAMpriceLabel( JLabel ramPriceLabel ){ this.ramPriceLabel = ramPriceLabel; }
	
	private JTextField minRAMpriceTextField;
	public JTextField getMinRAMpriceTextField(){ return minRAMpriceTextField; }
	public void setMinRAMpriceTextField( JTextField minRAMpriceTextField ){ this.minRAMpriceTextField = minRAMpriceTextField; }
	
	private JTextField maxRAMpriceTextField;
	public JTextField getMaxRAMpriceTextField(){ return maxRAMpriceTextField; }
	public void setMaxRAMpriceTextField( JTextField maxRAMpriceTextField ){ this.maxRAMpriceTextField = maxRAMpriceTextField; }
		
	private JLabel storageLabel;
	public JLabel getStorageLabel(){ return storageLabel; }
	public void setStorageLabel( JLabel storageLabel ){ this.storageLabel = storageLabel; }
	
	private JTextField minStorageTextField;
	public JTextField getMinStorageTextField(){ return minStorageTextField; }
	public void setMinStorageTextField( JTextField minStorageTextField ){ this.minStorageTextField = minStorageTextField; }
	
	private JTextField maxStorageTextField;
	public JTextField getMaxStorageTextField(){ return maxStorageTextField; }
	public void setMaxStorageTextField( JTextField maxStorageTextField ){ this.maxStorageTextField = maxStorageTextField; }
	
	private JLabel storagePriceLabel;
	public JLabel getStoragePriceLabel(){ return storagePriceLabel; }
	public void setStoragePriceLabel( JLabel storagePriceLabel ){ this.storagePriceLabel = storagePriceLabel; }
	
	private JTextField minStoragePriceTextField;
	public JTextField getMinStoragePriceTextField(){ return minStoragePriceTextField; }
	public void setMinStoragePriceTextField( JTextField minStoragePriceTextField ){ this.minStoragePriceTextField = minStoragePriceTextField; }
	
	private JTextField maxStoragePriceTextField;
	public JTextField getMaxStoragePriceTextField(){ return maxStoragePriceTextField; }
	public void setMaxStoragePriceTextField( JTextField maxStoragePriceTextField ){ this.maxStoragePriceTextField = maxStoragePriceTextField; }
	
	private JLabel maxVirtualNodesNumberLabel;
	public JLabel getMaxVirtualNodesNumberLabel(){ return maxVirtualNodesNumberLabel; }
	public void setMaxVirtualNodesNumberLabel( JLabel maxVirtualNodesNumberLabel ){ this.maxVirtualNodesNumberLabel = maxVirtualNodesNumberLabel; }
	
	private JTextField maxVirtualNodesNumberTextField;
	public JTextField getMaxVirtualNodesNumberTextField(){ return maxVirtualNodesNumberTextField; }
	public void setMaxVirtualNodesNumberTextField( JTextField maxVirtualNodesNumberTextField ){ this.maxVirtualNodesNumberTextField = maxVirtualNodesNumberTextField; }
	
	private JLabel bwLabel;
	public JLabel getBWlabel(){ return bwLabel; }
	public void setBWlabel( JLabel bwLabel ){ this.bwLabel = bwLabel; }
	
	private JTextField minBWtextField;
	public JTextField getMinBWtextField(){ return minBWtextField; }
	public void setMinBWtextField( JTextField minBWtextField ){ this.minBWtextField = minBWtextField; }
    
	private JTextField maxBWtextField;
	public JTextField getMaxBWtextField(){ return maxBWtextField; }
	public void setMaxBWtextField( JTextField maxBWtextField ){ this.maxBWtextField = maxBWtextField; }

	private JLabel bwPriceLabel;
	public JLabel getBWpriceLabel(){ return bwPriceLabel; }
	public void setBWpriceLabel( JLabel bwPriceLabel ){ this.bwPriceLabel = bwPriceLabel; }
	
	private JTextField minBWpriceTextField;
	public JTextField getMinBWpriceTextField(){ return minBWpriceTextField; }
	public void setMinBWpriceTextField( JTextField minBWpriceTextField ){ this.minBWpriceTextField = minBWpriceTextField; }	
	
	private JTextField maxBWpriceTextField;
	public JTextField getMaxBWpriceTextField(){ return maxBWpriceTextField; }
	public void setMaxBWpriceTextField( JTextField maxBWpriceTextField ){ this.maxBWpriceTextField = maxBWpriceTextField; }
	
	private JLabel distanceLabel;
	public JLabel getDistanceLabel(){ return distanceLabel; }
	public void setDistanceLabel( JLabel distanceLabel ){ this.distanceLabel = distanceLabel; }
	
	private JTextField minDistanceTextField;
	public JTextField getMinDistanceTextField(){ return minDistanceTextField; }
	public void setMinDistanceTextField( JTextField minDistanceTextField ){ this.minDistanceTextField = minDistanceTextField; }
    
	private JTextField maxDistanceTextField;
	public JTextField getMaxDistanceTextField(){ return maxDistanceTextField; }
	public void setMaxDistanceTextField( JTextField maxDistanceTextField ){ this.maxDistanceTextField = maxDistanceTextField; }
	
	private JLabel informationLabel;
	public JLabel getInformationLabel(){ return informationLabel; }
	public void setInformationLabel( JLabel informationLabel ){ this.informationLabel = informationLabel; }
	
	public CreateSdnSelectPanel()
    {   
    	this.setLayout( new BorderLayout() );
        this.add( this.titlePanel(), BorderLayout.NORTH );
        this.add( this.contentPanel(), BorderLayout.CENTER );
    }
	private JPanel titlePanel()
	{
        JLabel titleLabel = new JLabel( "Random SDN networks" );
        titleLabel.setFont( new Font( "MS Sans Serif", Font.BOLD, 14 ) );
        titleLabel.setBorder( new EmptyBorder( new Insets( 10, 10, 10, 10 ) ) );
        titleLabel.setOpaque( true );
        
        JPanel titlePanel = new JPanel();
        titlePanel.setLayout( new BorderLayout() );
        titlePanel.setBackground( Color.gray );
        titlePanel.add( titleLabel, BorderLayout.CENTER );
        titlePanel.add( new JSeparator(), BorderLayout.SOUTH );
        
        return titlePanel;
	}
	private JPanel contentPanel()
	{
		JPanel informationPanel = this.informationPanel();
		JPanel networksPanel = this.networksPanel();
		JPanel nodesPanel = this.nodesPanel();
		JPanel nodePanel = this.nodePanel();
		JPanel linkPanel = this.linkPanel();
		
        JPanel contentPanel = new JPanel();
        
		GroupLayout groupLayout = new GroupLayout( contentPanel );
		groupLayout.setAutoCreateGaps( true );
		groupLayout.setAutoCreateContainerGaps( true );
		groupLayout.setHorizontalGroup( groupLayout.createSequentialGroup().addGroup( groupLayout.createParallelGroup().addComponent( informationPanel ).addComponent( networksPanel ).addComponent( nodesPanel ).addComponent( nodePanel ).addComponent( linkPanel ) ) );
		groupLayout.setVerticalGroup( groupLayout.createParallelGroup().addGroup( groupLayout.createSequentialGroup().addComponent( informationPanel ).addComponent( networksPanel ).addComponent( nodesPanel ).addComponent( nodePanel ).addComponent( linkPanel ) ) );
		contentPanel.setLayout( groupLayout );
        
        return contentPanel;
	}
	
    private JPanel informationPanel()
	{
		this.setInformationLabel( new JLabel() );
		
		JPanel informationPanel = new JPanel();
		informationPanel.add( this.getInformationLabel() );
		
		return informationPanel;
	}
	
	private JPanel networksPanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>SDN NETWORKS</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel networksPanel = new JPanel();
        networksPanel.setLayout( new GridLayout( 0, 1 ) );
        networksPanel.setBorder( titledBorder );
        networksPanel.add( this.networksNumberPanel() );
        
        return networksPanel;
	}
    private JPanel networksNumberPanel()
    {
    	this.setNetworksNumberLabel( new JLabel( "<html><b>Networks number:</b></html>" ) );
    	this.setNetworksNumberTextField( new JTextField( Integer.toString( SdnNetworks.NETWORKS_NUMBER ) ) );
    	this.getNetworksNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getNetworksNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel networksNumberPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        networksNumberPanel.add( this.getNetworksNumberLabel() );
        networksNumberPanel.add( this.getNetworksNumberTextField() );
        
        return networksNumberPanel;
    }
    
    private JPanel nodesPanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>SDN NODES</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel nodesPanel = new JPanel();
        nodesPanel.setLayout( new GridLayout( 0, 1 ) );
        nodesPanel.setBorder( titledBorder );
        nodesPanel.add( this.routersNumberRangePanel() );
        nodesPanel.add( this.switchesNumberRangePanel() );
        nodesPanel.add( this.serversNumberRangePanel() );
        nodesPanel.add( this.osPercentagesPanel() );
        
        return nodesPanel;
	}
    private JPanel routersNumberRangePanel()
    {
    	this.setRoutersNumberLabel( new JLabel( "<html><b>Routers number:</b></html>" ) );
    	
    	this.setMinRoutersNumberTextField( new JTextField( Integer.toString( SdnNetworks.MIN_ROUTERS_NUMBER ) ) );
        this.getMinRoutersNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
        this.getMinRoutersNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
        this.setMaxRoutersNumberTextField( new JTextField( Integer.toString( SdnNetworks.MAX_ROUTERS_NUMBER ) ) );
        this.getMaxRoutersNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
        this.getMaxRoutersNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel routersNumberRangePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	routersNumberRangePanel.add( this.getRoutersNumberLabel() );
    	routersNumberRangePanel.add( new JLabel( "Between" ) );
    	routersNumberRangePanel.add( this.getMinRoutersNumberTextField() );
        routersNumberRangePanel.add( new JLabel( "and" ) );
        routersNumberRangePanel.add( this.getMaxRoutersNumberTextField() );
        
        return routersNumberRangePanel;
    }
    private JPanel switchesNumberRangePanel()
    {
    	this.setSwitchesNumberLabel( new JLabel( "<html><b>Switches number:</b></html>" ) );
    	
    	this.setMinSwitchesNumberTextField( new JTextField( Integer.toString( SdnNetworks.MIN_SWITCHES_NUMBER ) ) );
        this.getMinSwitchesNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
        this.getMinSwitchesNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
        this.setMaxSwitchesNumberTextField( new JTextField( Integer.toString( SdnNetworks.MAX_SWITCHES_NUMBER ) ) );
        this.getMaxSwitchesNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
        this.getMaxSwitchesNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel switchesNumberRangePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	switchesNumberRangePanel.add( this.getSwitchesNumberLabel() );
    	switchesNumberRangePanel.add( new JLabel( "Between" ) );
    	switchesNumberRangePanel.add( this.getMinSwitchesNumberTextField() );
        switchesNumberRangePanel.add( new JLabel( "and" ) );
        switchesNumberRangePanel.add( this.getMaxSwitchesNumberTextField() );
        
        return switchesNumberRangePanel;
    }
    private JPanel serversNumberRangePanel()
    {
    	this.setServersNumberLabel( new JLabel( "<html><b>Servers number:</b></html>" ) );
    	
    	this.setMinServersNumberTextField( new JTextField( Integer.toString( SdnNetworks.MIN_SERVERS_NUMBER ) ) );
        this.getMinServersNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
        this.getMinServersNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
        this.setMaxServersNumberTextField( new JTextField( Integer.toString( SdnNetworks.MAX_SERVERS_NUMBER ) ) );
        this.getMaxServersNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
        this.getMaxServersNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel serversNumberRangePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	serversNumberRangePanel.add( this.getServersNumberLabel() );
    	serversNumberRangePanel.add( new JLabel( "Between" ) );
    	serversNumberRangePanel.add( this.getMinServersNumberTextField() );
        serversNumberRangePanel.add( new JLabel( "and" ) );
        serversNumberRangePanel.add( this.getMaxServersNumberTextField() );
        
        return serversNumberRangePanel;
    }
    private JPanel osPercentagesPanel()
    {
    	this.setOSlabel( new JLabel( "<html><b>Operating systems %:</b></html>" ) );
    	    	
    	this.setLinuxPercentageTextField( new JTextField( Integer.toString( SdnNetworks.LINUX_PERCENTAGE ) ) );
    	this.getLinuxPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getLinuxPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setWindowsPercentageTextField( new JTextField( Integer.toString( SdnNetworks.WINDOWS_PERCENTAGE ) ) );
    	this.getWindowsPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getWindowsPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setSolarisPercentageTextField( new JTextField( Integer.toString( SdnNetworks.SOLARIS_PERCENTAGE ) ) );
    	this.getSolarisPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getSolarisPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.getAndroidPercentageTextField( new JTextField( Integer.toString( SdnNetworks.ANDROID_PERCENTAGE ) ) );
    	this.getAndroidPercentageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getAndroidPercentageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel osPercentagePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	
    	osPercentagePanel.add( this.getOSlabel() );
    	
    	osPercentagePanel.add( new JLabel( "Linux:" ) );
    	osPercentagePanel.add( this.getLinuxPercentageTextField() );
    	
    	osPercentagePanel.add( new JLabel( "Windows:" ) );
    	osPercentagePanel.add( this.getWindowsPercentageTextField() );
    	
    	osPercentagePanel.add( new JLabel( "Solaris:" ) );
    	osPercentagePanel.add( this.getSolarisPercentageTextField() );
    	
    	osPercentagePanel.add( new JLabel( "Android:" ) );
    	osPercentagePanel.add( this.getAndroidPercentageTextField() );
    	
    	return osPercentagePanel;
    }
    
    private JPanel nodePanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>SDN NODE</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel nodePanel = new JPanel();
        nodePanel.setLayout( new GridLayout( 0, 1 ) );
        nodePanel.setBorder( titledBorder );
        nodePanel.add( this.cpuPanel() );
        nodePanel.add( this.ramPanel() );
        nodePanel.add( this.storagePanel() );
        nodePanel.add( this.maxVirtualNodesNumberPanel() );
        
        return nodePanel;
	}
    private JPanel cpuPanel()
    {
    	this.setCPUlabel( new JLabel( "<html><b>CPU:</b></html>" ) );
    	this.setMinCPUtextField( new JTextField( Integer.toString( SdnNetworks.MIN_CPU ) ) );
    	this.getMinCPUtextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinCPUtextField().setHorizontalAlignment( JTextField.CENTER );    	
    	this.setMaxCPUtextField( new JTextField( Integer.toString( SdnNetworks.MAX_CPU ) ) );
    	this.getMaxCPUtextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxCPUtextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setCPUpriceLabel( new JLabel( "<html><b>Unit price:</b></html>" ) );
    	this.setMinCPUpriceTextField( new JTextField( Integer.toString( SdnNetworks.MIN_CPU_PRICE ) ) );
    	this.getMinCPUpriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinCPUpriceTextField().setHorizontalAlignment( JTextField.CENTER );    	
    	this.setMaxCPUpriceTextField( new JTextField( Integer.toString( SdnNetworks.MAX_CPU_PRICE ) ) );
    	this.getMaxCPUpriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxCPUpriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel cpuPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	cpuPanel.add( this.getCPUlabel() );
    	cpuPanel.add( new JLabel( "Between" ) );
    	cpuPanel.add( this.getMinCPUtextField() );
    	cpuPanel.add( new JLabel( "and" ) );
    	cpuPanel.add( this.getMaxCPUtextField() );
    	cpuPanel.add( this.getCPUpriceLabel() );
    	cpuPanel.add( new JLabel( "Between" ) );
    	cpuPanel.add( this.getMinCPUpriceTextField() );
    	cpuPanel.add( new JLabel( "and" ) );
    	cpuPanel.add( this.getMaxCPUpriceTextField() );
        
        return cpuPanel;
    }
    private JPanel ramPanel()
    {
    	this.setRAMlabel( new JLabel( "<html><b>RAM:</b></html>" ) );
    	this.setMinRAMtextField( new JTextField( Integer.toString( SdnNetworks.MIN_RAM ) ) );
    	this.getMinRAMtextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinRAMtextField().setHorizontalAlignment( JTextField.CENTER );
    	this.setMaxRAMtextField( new JTextField( Integer.toString( SdnNetworks.MAX_RAM ) ) );
    	this.getMaxRAMtextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxRAMtextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setRAMpriceLabel( new JLabel( "<html><b>Unit price:</b></html>" ) );
    	this.setMinRAMpriceTextField( new JTextField( Integer.toString( SdnNetworks.MIN_RAM_PRICE ) ) );
    	this.getMinRAMpriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinRAMpriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.setMaxRAMpriceTextField( new JTextField( Integer.toString( SdnNetworks.MAX_RAM_PRICE ) ) );
    	this.getMaxRAMpriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxRAMpriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel ramPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	ramPanel.add( this.getRAMlabel() );
    	ramPanel.add( new JLabel( "Between" ) );
    	ramPanel.add( this.getMinRAMtextField() );
    	ramPanel.add( new JLabel( "and" ) );
    	ramPanel.add( this.getMaxRAMtextField() );
    	ramPanel.add( this.getRAMpriceLabel() );
    	ramPanel.add( new JLabel( "Between" ) );
    	ramPanel.add( this.getMinRAMpriceTextField() );
    	ramPanel.add( new JLabel( "and" ) );
    	ramPanel.add( this.getMaxRAMpriceTextField() );
        
        return ramPanel;
    }
    private JPanel storagePanel()
    {
    	this.setStorageLabel( new JLabel( "<html><b>Storage:</b></html>" ) );
    	this.setMinStorageTextField( new JTextField( Integer.toString( SdnNetworks.MIN_STORAGE ) ) );
    	this.getMinStorageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinStorageTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.setMaxStorageTextField( new JTextField( Integer.toString( SdnNetworks.MAX_STORAGE ) ) );
    	this.getMaxStorageTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxStorageTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setStoragePriceLabel( new JLabel( "<html><b>Unit price:</b></html>" ) );
    	this.setMinStoragePriceTextField( new JTextField( Integer.toString( SdnNetworks.MIN_STORAGE_PRICE ) ) );
    	this.getMinStoragePriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinStoragePriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	this.setMaxStoragePriceTextField( new JTextField( Integer.toString( SdnNetworks.MAX_STORAGE_PRICE ) ) );
    	this.getMaxStoragePriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxStoragePriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel storagePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
    	storagePanel.add( this.getStorageLabel() );
    	storagePanel.add( new JLabel( "Between" ) );
    	storagePanel.add( this.getMinStorageTextField() );
    	storagePanel.add( new JLabel( "and" ) );
    	storagePanel.add( this.getMaxStorageTextField() );
    	storagePanel.add( this.getStoragePriceLabel() );
    	storagePanel.add( new JLabel( "Between" ) );
    	storagePanel.add( this.getMinStoragePriceTextField() );
    	storagePanel.add( new JLabel( "and" ) );
    	storagePanel.add( this.getMaxStoragePriceTextField() );
    	
    	return storagePanel;
    }
    private JPanel maxVirtualNodesNumberPanel()
    {
    	this.setMaxVirtualNodesNumberLabel( new JLabel( "<html><b>Maximum virtual nodes number:</b></html>" )) ;
    	
    	this.setMaxVirtualNodesNumberTextField( new JTextField( Integer.toString( SdnNetworks.MAX_VIRTUAL_NODES_NUMBER ) ) );
    	this.getMaxVirtualNodesNumberTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMaxVirtualNodesNumberTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel maxVirtualNodesNumberPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        maxVirtualNodesNumberPanel.add( this.getMaxVirtualNodesNumberLabel() );
        maxVirtualNodesNumberPanel.add( this.getMaxVirtualNodesNumberTextField() );
        
        return maxVirtualNodesNumberPanel;
    }
    
    private JPanel linkPanel()
	{
    	TitledBorder titledBorder = BorderFactory.createTitledBorder( BorderFactory.createLineBorder( Color.black ), "<html><b>SDN LINK</b></html>" );
        titledBorder.setTitleJustification( TitledBorder.CENTER );
        
        JPanel linkPanel = new JPanel();
        linkPanel.setLayout( new GridLayout( 0, 1 ) );
        linkPanel.setBorder( titledBorder );
        linkPanel.add( this.bwPanel() );
        linkPanel.add( this.distancePanel() );
        
        return linkPanel;
	}
    private JPanel bwPanel()
    {
    	this.setBWlabel( new JLabel( "<html><b>Bandwidth:</b></html>" ) );
    	
    	this.setMinBWtextField( new JTextField( Integer.toString( SdnNetworks.MIN_BW ) ) );
    	this.getMinBWtextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinBWtextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setMaxBWtextField( new JTextField( Integer.toString( SdnNetworks.MAX_BW ) ) );
    	this.getMaxBWtextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinBWtextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setBWpriceLabel( new JLabel( "<html><b>Unit price:</b></html>" ) );
    	
    	this.setMinBWpriceTextField( new JTextField( Integer.toString( SdnNetworks.MIN_BW_PRICE ) ) );
    	this.getMinBWpriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinBWpriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setMaxBWpriceTextField( new JTextField( Integer.toString( SdnNetworks.MAX_BW_PRICE ) ) );
    	this.getMaxBWpriceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinBWpriceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel bwPanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        bwPanel.add( this.getBWlabel() );
        bwPanel.add( new JLabel( "Between" ) );
        bwPanel.add( this.getMinBWtextField() );
        bwPanel.add( new JLabel( "and" ) );
        bwPanel.add( this.getMaxBWtextField() );
        bwPanel.add( this.getBWpriceLabel() );
        bwPanel.add( new JLabel( "Between" ) );
        bwPanel.add( this.getMinBWpriceTextField() );
        bwPanel.add( new JLabel( "and" ) );
        bwPanel.add( this.getMaxBWpriceTextField() );
        
        return bwPanel;
    }
    private JPanel distancePanel()
    {
    	this.setDistanceLabel( new JLabel( "<html><b>Distance:</b></html>" ) );
    	
    	this.setMinDistanceTextField( new JTextField( Integer.toString( SdnNetworks.MIN_DISTANCE ) ) );
    	this.getMinDistanceTextField().setPreferredSize( new Dimension( 25, 20 ) );
    	this.getMinDistanceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	this.setMaxDistanceTextField( new JTextField( Integer.toString( SdnNetworks.MAX_DISTANCE ) ) );
    	this.getMaxDistanceTextField().setPreferredSize( new Dimension( 30, 20 ) );
    	this.getMinDistanceTextField().setHorizontalAlignment( JTextField.CENTER );
    	
    	JPanel distancePanel = new JPanel( new FlowLayout( FlowLayout.CENTER ) );
        distancePanel.add( this.getDistanceLabel() );
        distancePanel.add( new JLabel( "Between" ) );
        distancePanel.add( this.getMinDistanceTextField() );
        distancePanel.add( new JLabel( "and" ) );
        distancePanel.add( this.getMaxDistanceTextField() );
        
        return distancePanel;
    }
        
	public void addListeners( DocumentListener documentListener, ActionListener actionListener )
	{
		this.getNetworksNumberTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinRoutersNumberTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxRoutersNumberTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinSwitchesNumberTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxSwitchesNumberTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinServersNumberTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxServersNumberTextField().getDocument().addDocumentListener( documentListener );
		
		this.getLinuxPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getWindowsPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getSolarisPercentageTextField().getDocument().addDocumentListener( documentListener );
		this.getAndroidPercentageTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinCPUtextField().getDocument().addDocumentListener( documentListener );
		this.getMaxCPUtextField().getDocument().addDocumentListener( documentListener );
		this.getMinCPUpriceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxCPUpriceTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinRAMtextField().getDocument().addDocumentListener( documentListener );
		this.getMaxRAMtextField().getDocument().addDocumentListener( documentListener );
		this.getMinRAMpriceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxRAMpriceTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinStorageTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxStorageTextField().getDocument().addDocumentListener( documentListener );
		this.getMinStoragePriceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxStoragePriceTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMaxVirtualNodesNumberTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinBWtextField().getDocument().addDocumentListener( documentListener );
		this.getMaxBWtextField().getDocument().addDocumentListener( documentListener );
		this.getMinBWpriceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxBWpriceTextField().getDocument().addDocumentListener( documentListener );
		
		this.getMinDistanceTextField().getDocument().addDocumentListener( documentListener );
		this.getMaxDistanceTextField().getDocument().addDocumentListener( documentListener );
	}
    	
	public boolean check()
	{
		this.getInformationLabel().setText( "Press \"Next\" to create random physical networks" );
		this.getInformationLabel().setForeground( Color.BLACK );
		
		if(      !this.checkNetworksNumber() )			return false;
		
		else if( !this.checkRoutersNumber() )			return false;
		else if( !this.checkSwitchesNumber() )			return false;
		else if( !this.checkServersNumber() )			return false;
		else if( !this.checkOSpercentages() )			return false;
		
		else if( !this.checkCPU() )						return false;
		else if( !this.checkCPUprice() )				return false;
		else if( !this.checkRAM() )						return false;
		else if( !this.checkRAMprice() )				return false;
		else if( !this.checkStorage() )					return false;
		else if( !this.checkStoragePrice() )			return false;
		else if( !this.checkMaxVirtualNodesNumber() )	return false;
		
		else if( !this.checkBW() )						return false;
		else if( !this.checkBWprice() )					return false;
		else if( !this.checkDistance() )				return false;
		
		else 											return true;
	}
	
	private boolean checkNetworksNumber()
	{	
		int lowestNetworksNumber =  1;
		int highestNetworksNumber = 50;
		
		try
		{
			int networksNumber = Integer.parseInt( this.getNetworksNumberTextField().getText() );
			
			if( !( lowestNetworksNumber <= networksNumber && networksNumber <= highestNetworksNumber ) )
				throw new NumberFormatException();
			
			this.getNetworksNumberLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>A value between " + lowestNetworksNumber + " and " + highestNetworksNumber + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getNetworksNumberLabel().setForeground( Color.RED );
			
			return false;
		}
	}
	
	private boolean checkRoutersNumber()
	{
		int lowestMinRoutersNumber = 1;
		int highestMaxRoutersNumber = 50;
		
		try
		{
			int minRoutersNumber = Integer.parseInt( this.getMinRoutersNumberTextField().getText() );
			int maxRoutersNumber  = Integer.parseInt( this.getMaxRoutersNumberTextField().getText() );
			
			if( !( lowestMinRoutersNumber <= minRoutersNumber && minRoutersNumber <= maxRoutersNumber && maxRoutersNumber <= highestMaxRoutersNumber ) )
				throw new NumberFormatException();
			
			this.getRoutersNumberLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinRoutersNumber + " and maximum value " + highestMaxRoutersNumber + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getRoutersNumberLabel().setForeground( Color.RED );
			
			return false;
		}
	}
	private boolean checkSwitchesNumber()
	{
		int lowestMinSwitchesNumber = 1;
		int highestMaxSwitchesNumber = 50;
		
		try
		{
			int minSwitchesNumber = Integer.parseInt( this.getMinSwitchesNumberTextField().getText() );
			int maxSwitchesNumber  = Integer.parseInt( this.getMaxSwitchesNumberTextField().getText() );
			
			if( !( lowestMinSwitchesNumber <= minSwitchesNumber && minSwitchesNumber <= maxSwitchesNumber && maxSwitchesNumber <= highestMaxSwitchesNumber ) )
				throw new NumberFormatException();
			
			this.getSwitchesNumberLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinSwitchesNumber + " and maximum value " + highestMaxSwitchesNumber + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getSwitchesNumberLabel().setForeground( Color.RED );
			
			return false;
		}
	}
	private boolean checkServersNumber()
	{
		int lowestMinServersNumber = 1;
		int highestMaxServersNumber = 50;
		
		try
		{
			int minServersNumber = Integer.parseInt( this.getMinServersNumberTextField().getText() );
			int maxServersNumber  = Integer.parseInt( this.getMaxServersNumberTextField().getText() );
			
			if( !( lowestMinServersNumber <= minServersNumber && minServersNumber <= maxServersNumber && maxServersNumber <= highestMaxServersNumber ) )
				throw new NumberFormatException();
			
			this.getServersNumberLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinServersNumber + " and maximum value " + highestMaxServersNumber + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getServersNumberLabel().setForeground( Color.RED );
			
			return false;
		}
	}
    private boolean checkOSpercentages()
	{
		try
		{
			int linuxPercentage   = Integer.parseInt( this.getLinuxPercentageTextField().getText() );
			int windowsPercentage = Integer.parseInt( this.getWindowsPercentageTextField().getText() );
			int solarisPercentage = Integer.parseInt( this.getSolarisPercentageTextField().getText() );
			int androidPercentage = Integer.parseInt( this.getAndroidPercentageTextField().getText() );
								
			if( !( 0 <= linuxPercentage   && linuxPercentage   <= 100 ) || 
				!( 0 <= windowsPercentage && windowsPercentage <= 100 ) || 
				!( 0 <= solarisPercentage && solarisPercentage <= 100 ) || 
				!( 0 <= androidPercentage && androidPercentage <= 100 ) || 
				!( linuxPercentage + windowsPercentage + solarisPercentage + androidPercentage == 100 ) )
				throw new NumberFormatException();
			
			this.getOSlabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Operating systems of nodes must sum to 100</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getOSlabel().setForeground( Color.RED );
			
			return false;
		}
	}
    	
    private boolean checkCPU()
    {
    	int lowestMinCPU = 0;
    	int highestMaxCPU = 100;
    	
		try
		{
			int minCPU = Integer.parseInt( this.getMinCPUtextField().getText() );
			int maxCPU = Integer.parseInt( this.getMaxCPUtextField().getText() );
			
			if( !( lowestMinCPU <= minCPU && minCPU <= maxCPU && maxCPU <= highestMaxCPU ) )
				throw new NumberFormatException();
			
			this.getCPUlabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinCPU + " and maximum value " + highestMaxCPU + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getCPUlabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkCPUprice()
    {	
    	int lowestMinCPUprice = 0;
    	int highestMaxCPUprice = 100;
    	
		try
		{
			int minCPUprice = Integer.parseInt( this.getMinCPUpriceTextField().getText() );
			int maxCPUprice = Integer.parseInt( this.getMaxCPUpriceTextField().getText() );
			
			if( !( lowestMinCPUprice <= minCPUprice && minCPUprice <= maxCPUprice && maxCPUprice <= highestMaxCPUprice ) )
				throw new NumberFormatException();
			
			this.getCPUpriceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinCPUprice + " and maximum value " + highestMaxCPUprice + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getCPUpriceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkRAM()
    {
    	int lowestMinRAM = 0;
    	int highestMaxRAM = 100;
    	
		try
		{
			int minRAM = Integer.parseInt( this.getMinRAMtextField().getText() );
			int maxRAM = Integer.parseInt( this.getMaxRAMtextField().getText() );
			
			if( !( lowestMinRAM <= minRAM && minRAM <= maxRAM && maxRAM <= 100 ) )
				throw new NumberFormatException();
			
			this.getRAMlabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinRAM + " and maximum value " + highestMaxRAM + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getRAMlabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkRAMprice()
    {	
    	int lowestMinRAMprice = 0;
    	int highestMaxRAMprice = 100;
    	
		try
		{
			int minRAMprice = Integer.parseInt( this.getMinRAMpriceTextField().getText() );
			int maxRAMprice = Integer.parseInt( this.getMaxRAMpriceTextField().getText() );
			
			if( !( lowestMinRAMprice <= minRAMprice && minRAMprice <= maxRAMprice && maxRAMprice <= highestMaxRAMprice ) )
				throw new NumberFormatException();
			
			this.getRAMpriceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinRAMprice + " and maximum value " + highestMaxRAMprice + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getRAMpriceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkStorage()
    {
    	int lowestMinStorage = 0;
    	int highestMaxStorage = 100;
    	
		try
		{
			int minStorage = Integer.parseInt( this.getMinStorageTextField().getText() );
			int maxStorage = Integer.parseInt( this.getMaxStorageTextField().getText() );
			
			if( !( lowestMinStorage <= minStorage && minStorage <= maxStorage && maxStorage <= highestMaxStorage ) )
				throw new NumberFormatException();
			
			this.getStorageLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinStorage + " and maximum value " + highestMaxStorage + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getStorageLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkStoragePrice()
    {	
    	int lowestMinStoragePrice = 0;
    	int highestMaxStoragePrice = 100;
    	
		try
		{
			int minDiskStoragePrice = Integer.parseInt( this.getMinStoragePriceTextField().getText() );
			int maxDiskStoragePrice = Integer.parseInt( this.getMaxStoragePriceTextField().getText() );
			
			if( !( lowestMinStoragePrice <= minDiskStoragePrice && minDiskStoragePrice <= maxDiskStoragePrice && maxDiskStoragePrice <= highestMaxStoragePrice ) )
				throw new NumberFormatException();
			
			this.getStoragePriceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinStoragePrice + " and maximum value " + highestMaxStoragePrice + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getStoragePriceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkMaxVirtualNodesNumber()
	{	
		int lowestMaxVirtualNodesNumber = 1;
		int highestMaxVirtualNodesNumber = 50;
		
		try
		{
			int maxVirtualNodesNumber = Integer.parseInt( this.getMaxVirtualNodesNumberTextField().getText() );
			
			if( !( lowestMaxVirtualNodesNumber <= maxVirtualNodesNumber && maxVirtualNodesNumber <= highestMaxVirtualNodesNumber ) )
				throw new NumberFormatException();
			
			this.getMaxVirtualNodesNumberLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>A value between " + lowestMaxVirtualNodesNumber + " and " + highestMaxVirtualNodesNumber + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getMaxVirtualNodesNumberLabel().setForeground( Color.RED );
			
			return false;
		}
	}
    
    private boolean checkBW()
    {
    	int lowestMinBW = 0;
    	int highestMaxBW = 100;
    	
		try
		{
			int minBW = Integer.parseInt( this.getMinBWtextField().getText() );
			int maxBW = Integer.parseInt( this.getMaxBWtextField().getText() );
			
			if( !( lowestMinBW <= minBW && minBW <= maxBW && maxBW <= highestMaxBW ) )
				throw new NumberFormatException();
			
			this.getBWlabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinBW + " and maximum value " + highestMaxBW + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getBWlabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkBWprice()
    {	
    	int lowestMinBWprice = 0;
    	int highestMaxBWprice = 100;
    	
		try
		{
			int minBWprice = Integer.parseInt( this.getMinBWpriceTextField().getText() );
			int maxBWprice = Integer.parseInt( this.getMaxBWpriceTextField().getText() );
			
			if( !( lowestMinBWprice <= minBWprice && minBWprice <= maxBWprice && maxBWprice <= highestMaxBWprice ) )
				throw new NumberFormatException();
			
			this.getBWpriceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinBWprice + " and maximum value " + highestMaxBWprice + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getBWpriceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
    private boolean checkDistance()
    {
    	int lowestMinDistance = 1;
    	int highetsMaxDistance = 100;
    	
		try
		{
			int minDistance = Integer.parseInt( this.getMinDistanceTextField().getText() );
			int maxDistance = Integer.parseInt( this.getMaxDistanceTextField().getText() );
			
			if( !( lowestMinDistance <= minDistance && minDistance <= maxDistance && maxDistance <= highetsMaxDistance ) )
				throw new NumberFormatException();
			
			this.getDistanceLabel().setForeground( Color.BLACK );
			
			return true;
		}
		catch( NumberFormatException numberFormatException )
		{
			this.getInformationLabel().setText( "<html><b>Minimum value " + lowestMinDistance + " and maximum value " + highetsMaxDistance + "</b></html>" );
			this.getInformationLabel().setForeground( Color.RED );
			
			this.getDistanceLabel().setForeground( Color.RED );
			
			return false;
		}
    }
	
}
